package com.manlitech.cloudboot.baseboot.service;

import com.alibaba.fastjson.JSONObject;
import com.manlitech.cloudboot.interfacestore.dubbo.DubboCallBackServiceI;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboService;
import org.apache.dubbo.rpc.RpcContext;

import java.net.URLDecoder;
import java.util.Map;

/**
 * dubbo 服务实现
 * @author shensg
*/


@DubboService
@Slf4j
public class DubboCallBackServiceImpl implements DubboCallBackServiceI {
    @SneakyThrows
    @Override
    public String helloDubbo(String name) {
        String index = RpcContext.getContext().getAttachment("index");
        String attachmentMapStr = RpcContext.getContext().getAttachment("attachmentMapStr");
        Map<String,Object> attachmentMap = (Map) JSONObject.parse(attachmentMapStr);
        String traceId = attachmentMap.get("traceId").toString();
        String token = attachmentMap.get("token").toString();
        log.info("###### #### ####call back hello " + token);
        return "call back hello , " + name +" , index , " +index + " token ," +token +" traceId , "+traceId;
    }
}
